
import { Component, Emit, Prop } from 'vue-property-decorator';
import { BaseController, PageVO, DialogVO, YhRspType, YhResponseData, DateUtils } from '@yhfin/biz';
import { InvestMentReq } from '../model/InvestMentReq';
import DictionConstUtil, { SGU_CACHE } from '@/utils/diction-const-util';
import { changeOptions } from '@/utils/tools';

@Component({
    components: {},
    watch: {
    }
})
export default class InvestmentQueryController extends BaseController {
    private reqVO: InvestMentReq = new InvestMentReq();
    private unfold = false;
    private controlGrades = [
        { label: '-', value: '-' },
        { label: '法规', value: '法规' },
        { label: '专属', value: '专属' }

    ];

    fundStorage: any[] = [];
    fundGroupStorage: any[] = [];

    async mounted() {
        this.fundStorage = await SGU_CACHE('FundInfoByUser', '/fundInfo/list/byUser/like', []);
        this.fundGroupStorage = (await DictionConstUtil.FNFundGroup()) || [];
    }

    // 已选项前置
    get computedFundStorage() {
        const arr = changeOptions(this.reqVO.fundProductCodes, this.fundStorage, 'fundProductCode');
        return arr;
    }

    // 已选项前置
    get computedFundGroupStorage() {
        const arr = changeOptions(this.reqVO.fundGroups, this.fundGroupStorage, 'fundGroupCode');
        return arr;
    }

    search() {
        if (this.reqVO.hsEntryCode) {
            this.reqVO.hsEntryCodeList = this.reqVO.hsEntryCode.split(';')
        } else {
            this.reqVO.hsEntryCodeList = undefined
        }
        if (this.reqVO.htEntryCode) {
            this.reqVO.htEntryCodeList = this.reqVO.htEntryCode.split(';');
        } else {
            this.reqVO.htEntryCodeList = undefined
        }
        this.$emit('search', this.reqVO)
    }

    reset() {
        this.reqVO = new InvestMentReq();
        this.$emit('search', this.reqVO)
    }
}
